module RongCloud
  module Apis
    module User
      # for getting user token to handle next step things 
      def get_token(user_id, name, image_url)
        request("/user/getToken", {
          userId: user_id,
          name: name,
          portraitUri: image_url
        })
      end

      def refresh_user(user_id, name = nil, image_url = nil)
        params = {
          userId: user_id,
          name: name,
          portraitUri: image_url
        }

        params.reject!{
          |key, value|
          value.nil?
        }
        # since we are backend stuff, / as first char is ok
        # but if we are client side, maybe don't define / as first char
        request("/user/refresh", params)
      end

      def check_online(user_id)
        request("/user/checkOnline", {
          userId: user_id
        })
      end

      def block_user(user_id, minute)
        request("/user/block", {
          userId: user_id,
          minute: minute
        })
      end

      def unblock_user(user_id)
        request("/user/unblock", userId: user_id)
      end

      def blocked_users
        request("/user/blacklist/add", userId: user_id, blackUserId: black_user_id)
      end

      def blacklist_remove(user_id, black_user_id)
        request("/user/blacklist/remove", userId: user_id, blackUserId: black_user_id)
      end

      def blacklisted_users(user_id)
        request("/user/blacklist/query", userId: user_id)
      end

    end # end User
  end # end Apis
end # end RongCloud
